<div class="page-header">
    <h1>
        礼物赠送单据信息列表
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
        </small>
    </h1>
</div>
<div class="row">
    <div class="col-xs-12">
        <table id="dtpList" class="dataTable">
            <tfoot>
            <tr>
                <td colspan="6">本页合计：</td>
                <td>
                    <span name="Order_Num"/>
                </td>
                <td>
                    <span name="Order_Amt" class="tooltip-"/>
                </td>
                <td>
                    <span name="Order_Amt_Anchor" class="tooltip-"/>
                </td>
                <td>
                    <span name="Order_Amt_Family" class="tooltip-"/>
                </td>
                <td>
                    <span name="Order_Amt_Platform" class="tooltip-"/>
                </td>
                <td></td>
            </tr>
            </tfoot>
        </table>
        <div id="dtpList_filter" class="dataTables_filter">
            <div>
                <select id="dtpList_F_SType" class="selectpicker" data-style="btn btn-info btn-sm" data-width="90px">
                    <option value="">模糊查询</option>
                    <option data-divider="true"></option>
                    <option value="Order_No">单据号</option>
                    <option value="User_ID">送出人ID</option>
                    <option value="User_NickName">送出人昵称</option>
                    <option value="User_ID_Gift">接收人ID</option>
                    <option value="User_NickName_Gift">接收人昵称</option>
                    <option value="Family_Name">公会名</option>
                </select>
                <input id="dtpList_F_SValue" class="fvalue" type="text"/>
                <select id="dtpList_F_Family" style="width: 206px;" data-databind="Family"></select>
                <select id="dtpList_F_Gift" style="width: 186px;" data-databind="CommodityGift" placeholder="礼物查询..."></select>
                <input id="dtpList_F_UserID" type="text" style="width: 76px;" placeholder="送出人ID">
                <input id="dtpList_F_UserIDGift" type="text" style="width: 76px;" placeholder="接收人ID">
                <a id="dtpList_F_Advanced"></a>
                <button id="dtpList_F_Btn"></button>
            </div>
            <div>
                <input id="dtpList_F_StartDate" type="text" style="width: 76px;" placeholder="开始时间">
                <label>-</label>
                <input id="dtpList_F_EndDate" type="text" style="width: 76px;" placeholder="结束时间">
                <select id="dtpList_F_SelectDate"></select>
                <label><input id="dtpList_F_Lucky" type="checkbox"/>&nbsp;幸运</label>
                <label><input id="dtpList_F_IsTask" type="checkbox"/>&nbsp;任务</label>
            </div>
        </div>
    </div>
</div>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.min.js"></script>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.bootstrap.min.js"></script>
<script>
    $(function () {
        //region 时间输入框插件
        $('#dtpList_F_StartDate, #dtpList_F_EndDate').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: 2,
            autoclose: true
        });
        //endregion
        //region 绑定日期选择框
        $.KOC.Date.Select.Bind({
            eSelect: $('#dtpList_F_SelectDate'),
            eBegin: $('#dtpList_F_StartDate'),
            eEnd: $('#dtpList_F_EndDate')
        });
        //endregion
        //region dtpList
        $("#dtpList").dataTable({
            'aoColumns': [
                {
                    'sWidth': '120px', 'data': 'Order_No', 'sName': 'Order_No', 'sTitle': "单据号", 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).html($('<a/>').attr('data-openwindow', cellData).text(cellData));
                    }
                },
                {
                    'sWidth': '75px', 'data': 'User_ID_Anchor', 'sName': 'User_ID_Anchor', 'sTitle': '房间ID', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).html($('<a/>').attr('data-openwindow', ':UserAnchorInfo:' + cellData).text(cellData));
                    }
                },
                {
                    'sWidth': '12%', 'data': 'Family_Name', 'sName': 'Family_ID', 'sTitle': '公会名', 'sClass': 'center t-left'
                },
                {
                    'sWidth': '10%', 'data': 'User_ID', 'sName': 'User_ID', 'sTitle': '送出人', 'sClass': 'center t-left',
                    'createdCell': function (td, cellData, rowData) {
                        $(td).html($('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).text(rowData.User_NickName));
                    }
                },
                {
                    'sWidth': '10%', 'data': 'User_ID_Gift', 'sTitle': '接收人', 'sClass': 'center t-left',
                    'createdCell': function (td, cellData, rowData) {
                        $(td).html($('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).text(rowData.User_NickName_Gift));
                    }
                },
                {
                    'sWidth': '12%', 'data': 'Gift_Name', 'sTitle': '礼物名称', 'sClass': 'center t-left', bSortable: false,
                    'createdCell': function (td, cellData, rowData) {
                        var _html = cellData;
                        if (rowData.Lucky) {
                            _html += ' <i class="fa fa-star bigger-120 purple" data-rel="tooltip" data-original-title="幸运礼物" />';
                        }
                        if (rowData.IsTask) {
                            _html += ' <i class="fa fa-tasks bigger-120 red" data-rel="tooltip" data-original-title="任务礼物" />';
                        }
                        $(td).html(_html);
                    }
                },
                {
                    'sWidth': '75px', 'data': 'Order_Num', 'sName': 'Order_Num', 'sTitle': '数量', 'sClass': 'center t-right'
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt', 'sName': 'Order_Amt', 'sTitle': '金额', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt_Anchor', 'sName': 'Order_Amt_Anchor', 'sTitle': '艺人收入', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt_Family', 'sName': 'Order_Amt_Family', 'sTitle': '公会收入', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '93px', 'data': 'Order_Amt_Platform', 'sName': 'Order_Amt_Platform', 'sTitle': '平台收入', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '13%', 'data': 'Create_Date', 'sName': 'Order_No', 'sTitle': '时间', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(moment(cellData).format('YY/MM/DD HH:mm'));
                    }
                }
            ],
            'aaSorting': [0, 'desc'],
            'sAjaxSource': '/ajax/user.page.ordergift',
            'fnServerParams': function (aoData) {
                if (!this.arrPageFilter) {
                    this.arrPageFilter = {
                        F_Family: $(this.selector + '_F_Family').val(),
                        F_Gift: $(this.selector + '_F_Gift').val(),
                        F_UserID: $(this.selector + '_F_UserID').val(),
                        F_UserIDGift: $(this.selector + '_F_UserIDGift').val(),
                        F_Lucky: $(this.selector + '_F_Lucky').is(':checked') ? 1 : -1,
                        F_IsTask: $(this.selector + '_F_IsTask').is(':checked') ? 1 : -1,
                        F_StartDate: $(this.selector + '_F_StartDate').val(),
                        F_EndDate: $(this.selector + '_F_EndDate').val()
                    };
                } else {
                    $(this.selector + '_F_Family').val(this.arrPageFilter.F_Family);
                    $(this.selector + '_F_Gift').val(this.arrPageFilter.F_Gift);
                    $(this.selector + '_F_UserID').val(this.arrPageFilter.F_UserID);
                    $(this.selector + '_F_UserIDGift').val(this.arrPageFilter.F_UserIDGift);
                    $(this.selector + '_F_Lucky').prop('checked', this.arrPageFilter.F_Lucky == 1);
                    $(this.selector + '_F_IsTask').prop('checked', this.arrPageFilter.F_IsTask == 1);
                    $(this.selector + '_F_StartDate').val(this.arrPageFilter.F_StartDate);
                    $(this.selector + '_F_EndDate').val(this.arrPageFilter.F_EndDate);
                }
                this.ofnServerParams(aoData);
            },
            'fnFooterCallback': function (nFoot, aData) {
                var _FooterData = {
                    Order_Num: 0,
                    Order_Amt: 0,
                    Order_Amt_Anchor: 0,
                    Order_Amt_Family: 0,
                    Order_Amt_Platform: 0
                };
                _.forEach(aData, function (ThisValue) {
                    _FooterData.Order_Num += ThisValue.Order_Num;
                    _FooterData.Order_Amt += ThisValue.Order_Amt;
                    _FooterData.Order_Amt_Anchor += ThisValue.Order_Amt_Anchor;
                    _FooterData.Order_Amt_Family += ThisValue.Order_Amt_Family;
                    _FooterData.Order_Amt_Platform += ThisValue.Order_Amt_Platform;
                });
                $(nFoot).find('[name="Order_Num"]').text(_FooterData.Order_Num);
                $(nFoot).find('[name="Order_Amt"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt / 1000)
                }).text(_FooterData.Order_Amt);
                $(nFoot).find('[name="Order_Amt_Anchor"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt_Anchor / 1000)
                }).text(_FooterData.Order_Amt_Anchor);
                $(nFoot).find('[name="Order_Amt_Family"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt_Family / 1000)
                }).text(_FooterData.Order_Amt_Family);
                $(nFoot).find('[name="Order_Amt_Platform"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Order_Amt_Platform / 1000)
                }).text(_FooterData.Order_Amt_Platform);
            },
            'fnDrawCallback': function () {
                $.Common.Bootstrap.Tooltip(this);
                this.ofnDrawCallback();
            },
            'selectOpt': {}
        });
        //endregion
    });
</script>